/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InQueue.java
 *
 * Created on 05/09/2011, 1:56:09 PM
 */
package liftsimulator;

import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Michael Peever & Alex Pool
 */
public class QueueIn extends javax.swing.JPanel /*implements Runnable*/ {

    int floorNumber;
    int noWaiting = 0;
    String stringOne = "";
    List<String> stringArray = new ArrayList<String>();

    /** Creates new form InQueue */
    public QueueIn(int floorNumber, int width, int height) {
        this.floorNumber = floorNumber;
        initComponents();
        this.temp.setText("");
        this.setPreferredSize(new Dimension(width, height));
    }

    public void addIDToStringArray(int id, int destFloor){
        stringOne = "("+ "[" + Integer.toString(id) + "]F:" + Integer.toString(destFloor) + ") "  ;
        stringArray.add(stringOne); 
    }
    
    public String createMasterString(){
        String masterString = "";
        for (int i = 0; i < stringArray.size(); i++){
            masterString = masterString + stringArray.get(i);
        }
        return masterString;
        
    }
    
    public void removeIDFromLift(int id, int destFloor){
        String tempString = "";
        tempString = "("+ "[" + Integer.toString(id) + "]F:" + Integer.toString(destFloor) + ") ";
       for (int i = 0; i < stringArray.size(); i++){
           if (tempString.equals(stringArray.get(i))){
               stringArray.remove(i);
           }
       }
    }
    public void incrementWaitingLabel() {
        noWaiting++;
        this.temp.setText(createMasterString());
    }

    public void decrementWaitingLabel() {
        noWaiting--;
        this.temp.setText(createMasterString());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        temp = new javax.swing.JLabel();

        setBackground(new java.awt.Color(153, 255, 0));
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        temp.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        temp.setText("0");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(temp, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(temp, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JLabel temp;
    // End of variables declaration//GEN-END:variables
}
